import { ModelConfig } from '../types';
const apiKey="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"
export const models: ModelConfig[] = [
{
    name: "deepseek/deepseek-chat-v3-0324:free",
    apiKey: "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"
  },
   {
    name: "deepseek/deepseek-r1-0528:free",
    apiKey: "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"
  },
  {
    name: "qwen/qwen3-235b-a22b:free", 
    apiKey: "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"
  },
  
];

export class ModelManager {
  private currentModelIndex = 1;

  getCurrentModel(): ModelConfig {
    return models[this.currentModelIndex];
  }

  switchModel(index: number): boolean {
    if (index >= 0 && index < models.length) {
      this.currentModelIndex = index;
      return true;
    }
    return false;
  }

  switchModelByName(name: string): boolean {
    const index = models.findIndex(model => model.name === name);
    if (index !== -1) {
      this.currentModelIndex = index;
      return true;
    }
    return false;
  }

  getAllModels(): ModelConfig[] {
    return [...models];
  }

  getCurrentModelIndex(): number {
    return this.currentModelIndex;
  }

  listModels(): string {
    let result = '\n=== 可用模型列表 ===\n';
    
    models.forEach((model, index) => {
      const isCurrent = index === this.currentModelIndex;
      const prefix = isCurrent ? '► ' : '  ';
      
      result += `${prefix}${index}. ${model.name}\n`;
    });
    
    result += '\n使用 /model <索引> 切换模型\n';
    return result;
  }
}

export const modelManager = new ModelManager();
